﻿function SwingsViewModel(model) {
    var selfSwings = this;

    selfSwings.BitcoinState = ko.observable();
    selfSwings.Swings = ko.observableArray();

    if (model) {
        selfSwings.BitcoinState(new BitcoinViewModel(model.BitcoinState));
        selfSwings.Swings(ko.utils.arrayMap(model.Swings, function (item) {
            return new SwingViewModel(item);
        }));
    }
    else
        selfSwings.BitcoinState(new BitcoinViewModel());
}